package com.dataseek.iot.start.doc;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

/**
 * @author cc
 * @Title: 接口文档配置
 * @Description: 接口文档配置
 * @date 2021/8/269:04 上午
 * @since 1.0
 */
@Configuration
public class SwaggerConfig {

    Boolean swaggerEnabled=true;

    @Bean
    public Docket systemApi(){
        return new Docket(DocumentationType.OAS_30)
                .apiInfo(systemInfo())
                .enable(swaggerEnabled)
                .groupName("系统管理接口")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.dataseek.iot.sys.manager"))
                .paths(PathSelectors.any())
                .build()
                .pathMapping("/");
    }


    private ApiInfo systemInfo(){
        return new ApiInfoBuilder()
                .title("dc-links 物联网平台API开放目录 系统管理接口")
                .description("springboot | webflux | netty | IOT")
                .contact(new Contact("DATASEEK", "http://wwww.dataseek.com.cn", "maomaogou@dataseek.cn"))
                .version("1.0")
                .build();
    }

    @Bean
    public Docket loginApi(){
        return new Docket(DocumentationType.OAS_30)
                .apiInfo(loginInfo())
                .enable(swaggerEnabled)
                .groupName("登陆管理接口")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.dataseek.iot.auth.manager"))
                .paths(PathSelectors.any())
                .build()
                .pathMapping("/");

    }

    private ApiInfo loginInfo(){
        return new ApiInfoBuilder()
                .title("dc-links 物联网平台API开放目录 登陆接口")
                .description("springboot | webflux | netty | IOT")
                .contact(new Contact("DATASEEK", "http://wwww.dataseek.com.cn", "maomaogou@dataseek.cn"))
                .version("1.0")
                .build();
    }


    @Bean
    public Docket deviceApi(){
        return new Docket(DocumentationType.OAS_30)
                .apiInfo(deviceInfo())
                .enable(swaggerEnabled)
                .groupName("设备管理接口")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.dataseek.iot.device.manager"))
                .paths(PathSelectors.any())
                .build()
                .pathMapping("/");

    }

    private ApiInfo deviceInfo(){
        return new ApiInfoBuilder()
                .title("dc-links 物联网平台API开放目录 设备管理接口")
                .description("springboot | webflux | netty | IOT")
                .contact(new Contact("DATASEEK", "http://wwww.dataseek.com.cn", "maomaogou@dataseek.cn"))
                .version("1.0")
                .build();
    }

    @Bean
    public Docket DataApi(){
        return new Docket(DocumentationType.OAS_30)
                .apiInfo(analysisInfo())
                .enable(swaggerEnabled)
                .groupName("数据统计接口")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.dataseek.iot.analysis.manager"))
                .paths(PathSelectors.any())
                .build()
                .pathMapping("/");

    }

    private ApiInfo analysisInfo(){
        return new ApiInfoBuilder()
                .title("dc-links 物联网平台API开放目录 数据统计接口")
                .description("springboot | webflux | netty | IOT")
                .contact(new Contact("DATASEEK", "http://wwww.dataseek.com.cn", "maomaogou@dataseek.cn"))
                .version("1.0")
                .build();
    }

    @Bean
    public Docket OperationApi(){
        return new Docket(DocumentationType.OAS_30)
                .apiInfo(operationInfo())
                .enable(swaggerEnabled)
                .groupName("运维监控接口")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.dataseek.iot.operation.manager"))
                .paths(PathSelectors.any())
                .build()
                .pathMapping("/");

    }

    private ApiInfo operationInfo(){
        return new ApiInfoBuilder()
                .title("dc-links 物联网平台API开放目录 运维监控接口")
                .description("springboot | webflux | netty | IOT")
                .contact(new Contact("DATASEEK", "http://wwww.dataseek.com.cn", "maomaogou@dataseek.cn"))
                .version("1.0")
                .build();
    }

}
